<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>List of Items</title>
<%@ page
import="
com.stand.hardcode.entity.Item,com.stand.hardcode.entity.StandUser,com.stand.hardcode.database.PMF,java.util.*,javax.jdo.PersistenceManager,javax.jdo.Query,com.google.appengine.api.datastore.Key;"
%>
<%
	StandUser currentUser = (StandUser)request.getSession().getAttribute("currentUser");
List<Item> itemList = (List<Item>) request.getAttribute("itemList");
List<Item> userWishList = currentUser.getWishlist();
List<Integer> userWishListQuantity = currentUser.getWishlistQuantity();
%>
</head>
<body>
<h1> Hello <%=currentUser.getName() %></h1>
<h2>Your Wish List:</h2>
<%for (int i=0; i<userWishList.size(); i++) {
	Item item = userWishList.get(i);
	Integer quantity = userWishListQuantity.get(i);
%>
	<form action="/removeitemfromwishlist" method="POST">
		Item: <%=item.getTitle() %><br>
		Description: <%=item.getDescription() %><br>
		Price: $<%=item.getPrice() %><br>
		Creation Time: <%=item.getCreationTime() %><br>
		Quantity: <%=quantity %><br>
		<input type="hidden" name="itemId" value="<%=item.getKey().getId()%>">
		Quantity: <input type="number" name="quantity" min=1 value=1 max=<%=quantity %> />
		<input type="submit" value="Remove from Wishlist" />
	</form>
	<br><br>
<%}%>

<hr>

<h2>Viewing items...</h2>
<%for (Item i : itemList) {%>
	<form action="/additemtowishlist" method="POST">
		Item: <%=i.getTitle() %><br>
		Description: <%=i.getDescription() %><br>
		Price: $<%=i.getPrice() %><br>
		Creation Time: <%=i.getCreationTime() %><br>
		<input type="hidden" name="itemId" value="<%=i.getKey().getId()%>">
		Quantity: <input type="number" name="quantity" min=1 value=1 max=1000 />
		<input type="submit" value="Add to Wishlist" />
	</form>
	<br><br>
<%} %>
</body>
</html>